Page({
  data: {
   
   name:'',
   staffid:'',
   startdate:null,
   EndDate:null,
   totalDays:0,
   useDays:0,
   hasDays:0,
   note:'本年度年休假'

  },
  onLoad() {
  var that=this;

  dd.getStorage({
  key: 'staffid',
  success: function(res) 
  { 
    //console.log(res.data);
  that.setData({

   staffid:res.data

  });
      dd.httpRequest({

        
          //提交工号和授权码，如果授权码和工号对上了就返回姓名，然后保存工号到缓存
          //url: 'https://oapi.dingtalk.com/user/getuserinfo?access_token=' + access_token + '&code=' + code,
          url:'http://ding.tida-lighting.com/api/user/yearholiady?staffid='+that.data.staffid,
          success: function (res) {
          var ic=parseInt(res.data.iUseCalc);
          var iu=parseInt(res.data.iUseInput);
          var tt=res.data.iCount;
          var ius=ic+iu;
          var ls=tt-ius;
           
          that.setData({
          startdate:res.data.date0,
          EndDate:res.data.date1,
          totalDays:tt,
          useDays:ius,
          hasDays:ls,
          });

          console.log(res.data);
         },
        fail: (err) => {
           //dd.alert({content: JSON.stringify(err)})
           console.log(err);
        }

     });//发起结束


  },
  fail: function(res){
    dd.alert({content: res.errorMessage});
  }
});

  dd.getStorage({
  key: 'name',
  success: function(res) {
   // console.log(res.data);
  that.setData({

   name:res.data

  });
  },
  fail: function(res){
    dd.alert({content: res.errorMessage});
  }
});
    
 

   
    },
   onReady(){

 var that=this;
 //console.log('工号测试'+that.data.staffid);
 
      
 //3.0 发起调用请求
    
    },
    preyear:function(){
   var that=this;
   dd.httpRequest({

        
          //提交工号和授权码，如果授权码和工号对上了就返回姓名，然后保存工号到缓存
          //url: 'https://oapi.dingtalk.com/user/getuserinfo?access_token=' + access_token + '&code=' + code,
          url:'http://ding.tida-lighting.com/api/user/preyearholiady?staffid='+that.data.staffid,
          success: function (res) {
          var ic=parseInt(res.data.iUseCalc);
          var iu=parseInt(res.data.iUseInput);
          var tt=res.data.iCount;
          var ius=ic+iu;
          var ls=tt-ius;
           
          that.setData({
          startdate:res.data.date0,
          EndDate:res.data.date1,
          totalDays:tt,
          useDays:ius,
          hasDays:ls,
          });

          console.log(res.data);
         },
        fail: (err) => {
           //dd.alert({content: JSON.stringify(err)})
           console.log(err);
        }

     });//发起结束


    }




  
});
